


//% color="#AA278D"
namespace MpythonGeomagnetism {


    //% block="Init" blockType="command"
    export function MpythonGeomagnetismBegin(parameter: any, block: any) {
        Generator.addInclude('MpythonGeomagnetismBegininclude', '#include "MMC5983MA.h"');
        Generator.addObject("MpythonGeomagnetismBeginobject", "MMC5983MA", "mmc");
        Generator.addSetup("MpythonGeomagnetismBeginsetup", `mmc.begin();`);
    }

    //% block="Calibration" blockType="command"
    export function MpythonGeomagnetismCalibration(parameter: any, block: any) {

        Generator.addCode("mmc.cal();");
    }

    //% block="Peeling" blockType="command"
    export function MpythonGeomagnetismPeeling(parameter: any, block: any) {

        Generator.addCode("mmc.peeling();");
    }

     //% block="Get heading " blockType="reporter"
     export function MpythonGeomagnetismGetheading(parameter: any, block: any) {

        Generator.addCode(["mmc.get_heading()",Generator.ORDER_UNARY_POSTFIX]);
    }

     //% block="Get field strength " blockType="reporter"
     export function MpythonGeomagnetismGet_field_strength(parameter: any, block: any) {

        Generator.addCode(["mmc.get_field_strength()",Generator.ORDER_UNARY_POSTFIX]);
    }

     //% block="Magnetic force of [DIR] axis" blockType="reporter"
     //% DIR.shadow="dropdown" DIR.options="AXIS"
     export function MpythonGeomagnetismGetmagnetic(parameter: any, block: any) {
        let dir = parameter.DIR.code;
        if(dir === "X" ){
            Generator.addCode("mmc.get_Xraw()");
        }else if(dir === "Y"){
            Generator.addCode("mmc.get_Yraw()");
        }else if(dir === "Z"){
            Generator.addCode("mmc.get_Zraw()");
        }
    }

}
